package com.lan.springbootdruid.datasource;

import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * @author: Lan
 * @date: 2019/5/5 17:57
 * @description:
 */
@Slf4j
public class DynamicRoutingDataSource extends AbstractRoutingDataSource {

    /**
     * 设置数据源
     *
     * @return
     */
    @Override
    protected Object determineCurrentLookupKey() {
        log.info("当前数据源：{}", DynamicDataSourceContextHolder.get());
        return DynamicDataSourceContextHolder.get();
    }
}
